package com.gongpb.langchain4j.demo.controller;

import com.gongpb.langchain4j.demo.AiKeys;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController("demo")
public class DemoController {
    @GetMapping("/agent")
    public String assistant(String message) {
        return "Hello, " + message;
    }


    @GetMapping("/chatmodel")
    public String modelChat(@RequestParam(value = "msg", defaultValue = "Hello") String message) {
        ChatLanguageModel model = OpenAiChatModel.builder()
                .apiKey(AiKeys.API_KEY)
                .baseUrl(AiKeys.API_URL_DEEPSEEK)
                .modelName(AiKeys.ModelName.DEEPSEEK_CHAT.getName())
                .build();
        String result = model.chat("你是谁？");
        System.out.println("end - result = " + result);
        return result;
    }
}
